﻿using CodeCity.Common;
using CodeCity.UserManagement.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeCity.UserMangament.Repository
{
    public class HouseRepository : RepositoryBase<House>
    {
        public HouseRepository(GameDbContext gameDbContext) : base(gameDbContext)
        {
        }

        public Task<int> CountTodayAsync()
        {
            return Query.Where(x => x.BuildingTime.Date == GameDateTime.Now.Date).CountAsync();
        }

        public Task<House> GetByUnitIdAsync(long id)
        {
            return Query.FirstOrDefaultAsync(x => x.UnitId == id);
        }
    }
}
